<template>
<el-dialog :visible.sync="isShow" width="1000px">
  <el-descriptions title="订单详情" :column="1" direction="vertical" border size='medium'>
    <el-descriptions-item label="基本信息">
      <el-form :inline="true">
        <el-form-item label="订单号：" style="width:30%"> {{ itemModel.orderId }} </el-form-item>
        <el-form-item label="三方交易单号：" style="width:30%" v-if="itemModel.transactionId"> {{ itemModel.transactionId }} </el-form-item>
        <el-form-item label="订单状态：" style="width:30%"> {{ itemModel.orderStatusLabel }} </el-form-item>
        <el-form-item label="发货时间：" style="width:30%"> {{ formatTime.dateFormat('YY-MM-DD hh:mm:ss', itemModel.createTime) }} </el-form-item>
        <el-form-item label="下单时间：" style="width:30%"> {{ formatTime.dateFormat('YY-MM-DD hh:mm:ss', itemModel.createTime) }} </el-form-item>
        <el-form-item label="付款时间：" style="width:30%"> {{ formatTime.dateFormat('YY-MM-DD hh:mm:ss', itemModel.payTime) }} </el-form-item>
        <el-form-item label="购买用户：" style="width:30%"> {{ itemModel.userModel.code }} </el-form-item>
        <el-form-item label="发货类型：" style="width:30%"> {{ itemModel.sendTypeLabel }} </el-form-item>
        <el-form-item label="买家备注：" style="width:30%"> {{ itemModel.remark?itemModel.remark:'无' }} </el-form-item>
        <el-form-item label="卖家备注：" style="width:30%"> {{ itemModel.remark_seller?itemModel.remark_seller:'无' }} </el-form-item>
      </el-form>
    </el-descriptions-item>
  </el-descriptions>
  <el-descriptions title="" :column="4" direction="vertical" border size='medium'>
    <el-descriptions-item label="物流信息" :labelStyle="{width: '400px'}">
      <template v-if="itemModel.orderStatus=='WAIT_SEND'">
        <el-form :model="itemModel" ref="itemModel" label-width="90px" label-position="right">
          <el-form-item label="收货人：" prop="contactName">
            <el-input v-model="itemModel.addrinfoDict.contactName" placeholder="收货人" clearable style="width: 200px;"></el-input>
          </el-form-item>
          <el-form-item label="联系电话：" prop="contactPhone">
            <el-input v-model="itemModel.addrinfoDict.contactPhone" placeholder="联系电话" clearable style="width: 200px;"></el-input>
          </el-form-item>
          <el-form-item label="详细地址：" prop="detailAddr">
            <el-input v-model="itemModel.addrinfoDict.addrInfo" placeholder="详细地址" clearable style="width: 200px;"></el-input>
          </el-form-item>
          <el-form-item label="快递公司" prop="expressageCompany">
            <el-input v-model="itemModel.expressageinfoDict.expressageCompany" placeholder="请选择快递公司" clearable style="width: 200px;"></el-input>
          </el-form-item>
          <el-form-item label="快递单号" prop="expressageNum" style="margin-top: 10px;">
            <el-input v-model="itemModel.expressageinfoDict.expressageNum" placeholder="请输入快递单号" clearable style="width: 200px;"></el-input>
          </el-form-item>
          <el-form-item label="" style="margin-top: 10px;">
            <el-button type="primary" @click="updateExpressageNum" >保存</el-button>
          </el-form-item>
        </el-form>
       </template>
      <template v-else>
        <el-form label-width="90px">
          <el-form-item label="收货人："> {{ itemModel.addrinfoDict.contactName }} </el-form-item>
          <el-form-item label="联系电话："> {{ itemModel.addrinfoDict.contactPhone }} </el-form-item>
          <el-form-item label="收货地址："> {{ itemModel.addrinfoDict.addrInfo }} </el-form-item>
        </el-form>
        <el-form :model="itemModel" ref="itemModel" label-width="90px" label-position="right">
          <el-form-item label="快递公司" prop="expressageCompany">
            <el-input v-model="itemModel.expressageinfoDict.expressageCompany" placeholder="请选择快递公司" clearable style="width: 200px;"></el-input>
          </el-form-item>
          <el-form-item label="快递单号" prop="expressageNum" style="margin-top: 10px;">
            <el-input v-model="itemModel.expressageinfoDict.expressageNum" placeholder="请输入快递单号" clearable style="width: 200px;"></el-input>
          </el-form-item>
          <el-form-item label="" style="margin-top: 10px;">
            <el-button type="primary" @click="updateExpressageNum" >保存</el-button>
          </el-form-item>
        </el-form>
      </template>
       
        
    </el-descriptions-item>
    <el-descriptions-item label="支付信息">
        <el-form>
            <el-form-item label="实付金额："> {{ itemModel.realPay }} </el-form-item>
            <el-form-item label="付款方式："> {{ itemModel.paywayLabel }} </el-form-item>
            <el-form-item label="付款时间："> {{ formatTime.dateFormat('YY-MM-DD hh:mm:ss', itemModel.payTime) }} </el-form-item>
        </el-form>
    </el-descriptions-item>
    <el-descriptions-item label="买家信息">
        <el-form>
            <el-form-item label="买家昵称："> {{ itemModel.userModel.nickname?itemModel.userModel.nickname:'未设置' }} </el-form-item>
            <el-form-item label="买家ID："> {{ itemModel.userModel.code }} </el-form-item>
            <el-form-item label="买家手机号："> {{ itemModel.userModel.phone }} </el-form-item>
        </el-form>
    </el-descriptions-item>
  </el-descriptions>
  <el-descriptions title="" :column="1" direction="vertical" border size='medium'>
    <el-descriptions-item label="商品信息">
      <el-table :data="itemModel.itemList" size='medium'>
        <el-table-column prop="item" label="ID" width="50px" show-overflow-tooltip></el-table-column>
            <el-table-column prop="coverUrl" label="商品图片" show-overflow-tooltip>
                <template slot-scope="scope"><img width="50" height="50" :src="scope.row.coverUrl"></template>
            </el-table-column>
            <el-table-column prop="itemName" label="商品名称" show-overflow-tooltip></el-table-column>
            <el-table-column prop="itemName" label="商品规格" show-overflow-tooltip>
              <template slot-scope="{ row, idnex }">
                {{ formData.getSpecs(row.specValues) }}
              </template>
            </el-table-column>
            <el-table-column prop="priceModel.sellingPrice" label="销售价格" show-overflow-tooltip></el-table-column>
            <el-table-column prop="priceModel.costPrice" label="成本价格" show-overflow-tooltip></el-table-column>
            <el-table-column prop="payCount" label="数量" show-overflow-tooltip></el-table-column>
        </el-table>
    </el-descriptions-item>
  </el-descriptions>
  <el-descriptions title="" :column="1" direction="vertical" border size='medium'>
    <el-descriptions-item label="积分详情">
      <el-table :data="incomesLockedList" size='medium'>
        <el-table-column prop="orderId" label="关联订单" show-overflow-tooltip width="170"></el-table-column>
        <el-table-column prop="paywayLabel" label="账户类型" show-overflow-tooltip width="100"></el-table-column>
        <el-table-column prop="sceneLabel" label="奖励类型" show-overflow-tooltip width="120"></el-table-column>
        <el-table-column prop="userModel.code" label="用户ID" show-overflow-tooltip></el-table-column>
        <el-table-column prop="fromUserModel.code" label="来自用户ID" show-overflow-tooltip width="100"></el-table-column>
        <el-table-column prop="changeWay" label="变动方式">
          <template slot-scope="{row, index}">
            {{ row.changeWay=='add'?'增加':'减少' }}
          </template>
        </el-table-column>
        <el-table-column prop="money" label="金额" show-overflow-tooltip></el-table-column>
        </el-table>
    </el-descriptions-item>
  </el-descriptions>
</el-dialog>
</template>

<script>
  import {
 updateOrder, getOrderById
} from '@/api/pay/order.js'
import { formData } from '@/views/pay/order/data'
import {
  findRecordIncomesLockedList
} from '@/api/pay/recordIncomesLocked.js'
import { findRecordIncomesList } from '@/api/pay/recordIncomes.js'
export default {
  components: {
    
  },
  data() {
    return {
        isShow: false,
        searchParams: {},
        rowId: '',
        itemModel: {addrinfoDict:{}, expressageinfoDict:{}, userModel:{}},
        formData,
        itemList: [],
        incomesLockedList: [],
        
    }
  },
  created(){
  },
  methods:{
    show(val){
      this.isShow = true
      if(val.rowId){
        this.rowId = val.rowId
        this.getOrderById()
      }
    },
    close(){
        this.isShow = false
    },
    getOrderById(){
      getOrderById({
        obj_id: this.rowId
      }).then(res => {
        if (res.data.code == 10000) {
          this.itemModel = res.data.data
          this.findInMoneyList()
        }
      });
    },
    findInMoneyList() {
        this.searchParams.orderId = this.itemModel.orderId
        findRecordIncomesList(this.searchParams).then(res => {
        if(res.data.code == 10000){
          this.totalSize = res.data.data.total_count
          this.incomesLockedList = res.data.data.list
        }
      });
    },
    updateExpressageNum(){

      var addrinfo = JSON.stringify(this.itemModel.addrinfoDict)
      var expressageinfo = JSON.stringify(this.itemModel.expressageinfoDict)

      updateOrder({
        obj_id: this.rowId,
        addrinfo: addrinfo,
        expressageinfo: expressageinfo
      }).then(res => {
        if(res.data.code == 10000){
          this.$message({
            message: '保存成功',
            type: 'success'
          })
        }
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.list-group {
  line-height: 1.15;
}

.show-pwd {
  position: absolute;
  right: 10px;
  top: 0px;
  font-size: 16px;
  cursor: pointer;
  user-select: none;
}

.el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 200px;
    margin: 0;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }

  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
  .photosItem{
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
  }
</style>
